var appPrefix="EXPO";

//显示/隐藏切换
function toggleDisplay(id){
	var eles;
	eles=document.getElementById(id);
	if(eles.style.display!="none"){
		eles.style.display="none";
	}else{
		eles.style.display="block";
	}
}
//打开货物图片上传page
function openFileViewWin(goodsId){
	openModalDialog("GoodsImgUpload.html?id="+goodsId,800,540);
}

//submit设定无效decl
//return boolean
function submitSetUnValidDecl(id){
	if(window.confirm("设定报检单无效将从系统中清除该记录,并且不会再从CIQ中获取该单,您确定吗？")){
		var form=document.getElementById("DeclModifyForm");
		form.action="DeclModify.do?opt=1&id="+id;
		form.submit();
		return true;
	}
	return false;
}

//void
function modifyDeclBackupCode(){
	var span=document.getElementById("backupCodeSpan");
	span.style.display="block";
}

function modifyDeclConsignorCname(){
	var span=document.getElementById("consignorCnameSpan");
	span.style.display="block";
}

//submit修改decl备案号
//return boolean
function submitModifyDeclBackupCode(id){
	document.getElementById("backupCodeInput").name="newbackupCode";
	var newbackupCode=document.getElementById("backupCodeInput").value.toUpperCase();
	if(newbackupCode.length<8||newbackupCode.indexOf(appPrefix)!=0){
		alert("备案号格式错误,正确格式类似'EXPO2010'");
		return false;
	}
	if(window.confirm("您确定修改报检单备案号吗？")){
		var form=document.getElementById("DeclModifyForm");
		form.action="DeclModify.do?opt=2&id="+id;
		form.submit();
		return true;
	}
	return false;
}

//submit修改decl发货人
//return boolean
function submitModifyDeclConsignor(id){
	document.getElementById("consignorCnameInput").name="newbackupCode";
	var newbackupCode=document.getElementById("consignorCnameInput").value.toUpperCase();
	if(window.confirm("您确定修改报检单的发货人吗？")){
		var form=document.getElementById("DeclModifyForm");
		form.action="DeclModify.do?opt=5&id="+id;
		form.submit();
		return true;
	}
	return false;
}

//submit更新decl检查结果
//return boolean
function submitUpdateDeclResult(id){
	if(window.confirm("将从CIQ数据库更新报检单查验结果,您确定吗？")){
		var form=document.getElementById("DeclModifyForm");
		form.action="DeclModify.do?opt=3&id="+id;
		form.submit();
		return true;
	}
	return false;
}

//submit 提交监管结果
//return boolean
function submitDeclSupervise(id){
	if(window.confirm("提交报检单监管结果后不再修改,您确定吗？")){
		var form=document.getElementById("DeclSuperviseForm");
		form.action="DeclModify.do?opt=4&id="+id;
		form.submit();
		return true;
	}
	return false;
}

//获取货物的ciq查验详情,ajax方式
//return void
/*
function queryInspectionResult(declId,goodsId,declNo,goodsNo,type){
	//	type信息类型 1=检验 2=检疫 3=木包装  4=集装箱
	var inspDetailSpan=document.getElementById("inspDetailSpan");
	var url;
	if(type==1){
		url="CheckInspectionResult.html";
	}else if(type==2){
		url="CheckQuarantineResult.html";
	}else if(type==3){
		url="CheckPackResult.html";
	}else if(type==4){
		url="CheckContainerResult.html";
	}
	var params={"declId":declId,"goodsId":goodsId,"declNo":declNo,"goodsNo":goodsNo};
	fetchAjaxPage(inspDetailSpan,url,params);
}
*/

function queryInspectionResult(declId,goodsId,type){
	var act=window.event.srcElement.tagName.toUpperCase();
	if(act=="IMG"){
		return;
	}
	//type 1=普货类 2=展品类
	var url="GoodsCheckInfo.html?declId="+declId+"&goodsId="+goodsId+"&type="+type;
	var win=openModalDialog(url,800,450,null,"scroll:1;");
}

//验证输入报检号位数
function validateDeclNumber(){
	var declNo=document.getElementById("declNo").value.trim();
	document.getElementById("declNo").value=declNo;
	if(declNo.length!=15){
		alert("请输入15位数字作为报检号");
		return false;
	}
	var re=/\D/;
	if(declNo.search(re)!=-1){
		alert("请输入15位数字作为报检号");
		return false;
	}
	return true;
}

//submit手工取单
function submitFetchDecl(){
	if(document.getElementById("fetchDeclNo").value.length!=15){
		return false;
	}
	if(document.getElementById("backupCode").value.length==0||
		document.getElementById("type").value.length==0){
		alert("请手工指定备案号和报检单类别");
		return false;
	}
	if(!window.confirm("您确定将此单从CIQ中提取到本系统吗？")){
		return false;
	}
	return true;
}

//submit将无效报检单重新设定有效
function submitValidDecl(vid){
	if(window.confirm("您是否从无效报检单列表中删除该报检号，重新手工或自动从CIQ中取该报检单？")){
		var form=document.getElementById("UnvalidDeclListForm");
		var type=document.getElementById("username");
		var id=document.getElementById("id");
		type.value="del";
		id.value=vid;
		form.submit();
	}else{
		return false;
	}
}

//报检单统计导出
function exportDecls(){
	if(window.confirm("如果数据较多该操作可能会执行较长时间，您确认要导出吗?")){
		var form=document.forms[0];
		var act=form.action;
		form.action="StatDeclsExport.do";
		form.submit();
		form.action=act;
		return true;
	}
	return false;
}
//货物统计导出
function exportGoods(){
	if(window.confirm("如果数据较多该操作可能会执行较长时间，您确认要导出吗?")){
		var form=document.forms[0];
		var act=form.action;
		form.action="StatGoodsExport.do";
		form.submit();
		form.action=act;
		return true;
	}
	return false;
}